import { ref, computed } from 'vue';
const useStyle = ({activeItem, props}) => {
    const scrollValue = ref(0);
    const panelItemClass = computed(() => (item) => {
        let className = [];
        if (activeItem.value.majorCode === item.majorCode) className.push('active');
        className.push('panel-item-hover');
        return className;
    });
    const activeStyle = computed(() => {
		let i = props.dataList.findIndex(x => x.majorCode === activeItem.value.majorCode);
        let top = 124 * i + scrollValue.value;
        let style = {
            '--top': `${top}px`
        };
        return style;
    });
    // 触摸去掉前一个兄弟元素的边框
    const handleMouse = (e, type) => {
        const prevNode = e.target.previousSibling;
        if (prevNode.nodeType === 1) prevNode.classList[type]('no-border');
    };
    // 滚动
    const changeScrollValue = (e) => {
        scrollValue.value = e.target.scrollTop;
    };
    return {
        activeStyle,
        panelItemClass,
        handleMouse,
        changeScrollValue
    };
};
export default useStyle;
